<template>
  <div>
    <div id="head">
      <van-icon size="25px" @click="toHead()" name="arrow-left"
                style="position: absolute;left: 10px;" />
      申请信息
    </div>
    <div>
      <van-cell class="custom-one" title="申请信息" icon="records-o" style="font-size: 18px">
        <van-button type="primary" size="small" v-if="this.applyForHome.applyStatus=='待审核'&this.user.pid==1"
                   @click="toPass()">通过</van-button>
      </van-cell>
    </div>
    <div>
      <van-cell-group>
        <van-cell class="custom-cell" title="申请类别" :value="applyForHome.applyType" />
        <van-cell class="custom-cell" title="申请人" :value="applyForHome.applyName" />
        <van-cell class="custom-cell" title="身份证号" :value="applyForHome.idNumber" />
        <van-cell class="custom-cell" title="入住日期":value="applyForHome.checkInTime" />
        <van-cell class="custom-cell" title="退房日期" :value="applyForHome.checkOutTime" />
        <van-cell class="custom-cell" title="所属部门" :value="applyForHome.deptType" />
        <van-field label="联系电话" placeholder="请输入联系电话" :value="applyForHome.phone" />
        <van-field  rows="2" autosize label="备注信息" type="textarea"
                   maxlength="50" placeholder="请输入备注" show-word-limit :value="applyForHome.notes"
        />
      </van-cell-group>
    </div>
    <div style="margin-top: 50px;padding: 10px" >
      <van-button type="info" round size="large" @click="toHead()">返回</van-button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { Dialog } from 'vant';
export default {
  data() {
    return {
      id:"",
      applyForHome:{},
      user:{},
      one:{},
    }
  },
  methods:{
    toPass(){
      Dialog.confirm({
        title: '住房申请',
        message: '确定要通过吗？',
      })
          .then(() => {
            axios.post("http://localhost:9999/myModule-service/applyForHome/updateStatus?id="+this.id).then(res=>{
              this.$toast("处理完成");
              this.findById();
            })
          })
          .catch(() => {
            // on cancel
          });
    },
    findById(){
      axios.post("http://localhost:9999/myModule-service/applyForHome/findById?id="+this.id).then(res=>{
        this.applyForHome = res.data;
      })
    },
    toHead(){
      this.$router.push('/applyForHome')
    },
    findOne(){
      axios.post("http://localhost:9999/api-user-service/user/findById?id="+this.aaa.userId).then(res=>{
        this.user = res.data;
      })
    },
  },
  created(){
    this.id= this.$route.query.id
    this.findById();
    this.aaa = JSON.parse(localStorage.getItem("aa"));
    this.findOne();
  }
}
</script>

<style scoped>
#head{
  background-color: #f5f5f5;
  height: 30px;
  width: 100%;
  padding-top: 10px;
  padding-bottom: 10px;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}
.custom-cell .van-cell__title {
  text-align: left;
  margin-bottom: 10px;
}
.custom-one .van-cell__title {
  text-align: left;

  min-width: 80%;
}
.custom-cell .van-cell__value {
  color: lightcoral;
  min-width: 70%;
  text-align: left;
  margin-bottom: 10px;
}
.custom-cell .van-cell__icon {
  color: blue;
}
</style>
